﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        private dataDataContext dc = new dataDataContext();
        private string _Myurl;

        public string Myurl
        {
            get { return _Myurl; }
            set { _Myurl = value; }
        }
        
        protected void Page_Load(object sender, EventArgs e)
        {
            Myurl = Request.Url.AbsolutePath;

            if (!Page.IsPostBack)
            {
                this.RepeaterSupplier.DataSource = this.dc.Suppliers.ToList();
                this.RepeaterSupplier.DataBind();
                this.RepeaterCategory.DataSource = this.dc.Categories.ToList();
                this.RepeaterCategory.DataBind();


             
                try
                {
                    Customer cus = this.dc.Customers.Where(k => k.CustomerID == 9).FirstOrDefault();
                    LabelnameSigin.Text = cus.Name.ToString();
                }
                catch (Exception ex)
                { 

                
                }
                
            }
        }
        public bool ktdangnhap(string tendangnhap, string matkhau)
        {
           return dc.Customers.Where(nd=>nd.Username == tendangnhap && nd.Password == matkhau).FirstOrDefault()!= null? true:false;
        }

        public void signin_submit_Click(object sender, EventArgs e)
        {
            bool ok = ktdangnhap(TextBox1.Text.ToString() ,TextBox2.Text.ToString());
            if(ok)
            {
                Labelstatus.Text = "dc roi do";
                
            }
            else
            Labelstatus.Text="eo dc roi";
        }
    }
}
